﻿using Orchard.ContentManagement;
using Orchard.Core.Common.Utilities;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace MultiChoiceVoting.Models
{
    public class MultiChoiceVotingPart : ContentPart<MultiChoiceVotingPartRecord>
    {
        [Required]
        public string Name { get { return Record.Name; } set { Record.Name = value; } }
        [Required]
        public string Question { get { return Record.Question; } set { Record.Question = value; } }
        [Required]
        public string AnswerList { get { return Record.AnswerList; } set { Record.AnswerList = value; } }
        public string Comment { get { return Record.Comment; } set { Record.Comment = value; } }
        [Required]
        public DateTime? ReleaseDate { get { return Record.ReleaseDate; } set { Record.ReleaseDate = value; } }
        [Required]
        public DateTime? FinishDate { get { return Record.FinishDate; } set { Record.FinishDate = value; } }
        [Required]
        public bool IsActive { get { return Record.IsActive; } set { Record.IsActive = value; } }
        public string SerializedAnswers { get { return Record.SerializedAnswers; } set { Record.SerializedAnswers = value; } }

        private readonly LazyField<IList<Answer>> _answers = new LazyField<IList<Answer>>();
        public LazyField<IList<Answer>> AnswersField { get { return _answers; } }
        public IList<Answer> Answers
        {
            get { return _answers.Value; }
        }
    }
}